package cn.qayy.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.qayy.dao.CostPMapper;
import cn.qayy.dto.CostDTO;
import cn.qayy.po.CostP;
import cn.qayy.service.ICostService;
import cn.qayy.utils.DownLoadUtil;
@Service("costServiceImpl")
@SuppressWarnings("all")
public class CostServiceImpl implements ICostService {
	private Logger logger = LoggerFactory.getLogger(CostServiceImpl.class);

	@Resource
	public CostPMapper costPMapper;
	
	@Override
	public PageInfo<CostP> selectForList(CostDTO dto) throws Exception{
		if (dto != null) {
			DownLoadUtil.set("CostDTO",dto);
			PageHelper.startPage(dto.getPageNumber(), dto.getPageSize());
			List<CostP> list = costPMapper.selectForList(dto);
			PageInfo<CostP> pageInfo = new PageInfo<CostP>(list);
			return pageInfo;
		}
		return null;
	}

	@Override
	public List<Map<String, Object>> selectForDown(CostDTO dto) throws Exception {
		List<Map<String, Object>> list = costPMapper.selectForDown(dto);
		return list;
	}

	@Override
	public CostP selectByID(@RequestParam Integer id) throws Exception {
		return costPMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByList(List list) throws Exception{
		return costPMapper.updateByList(list);
	}

	@Override
	public int deleteByList(List list) throws Exception{
		return costPMapper.deleteByList(list);
	}

	@Override
	public int insert(Object bean) throws Exception{
		return costPMapper.insert(bean);
	}

	@Override
	public int update(Object bean) throws Exception{
		return costPMapper.updateByPrimaryKey(bean);
	}

	@Override
	public int delete(Object bean) throws Exception{
		return costPMapper.delete(bean);
	}

	@Override
	public int insertByList(List list) throws Exception{
		return costPMapper.insertByList(list);
	}

	/*@Override
	public CostP selectLastOneByMap(Map<String, Object> params) throws Exception {
		return costPMapper.selectLastOneByMap(params);
	}*/

}
